/**
 * 2
 *  
 * @Author : roryrywang
 * @DateTime : 24-8-24 下午3:42
 */

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int m, n, q;
    cin >> m >> n >> q;
    bool g[m + 1][n + 1];
    for (int i = 0; i <= m; ++i) {
        for (int j = 0; j <= n; ++j) {
            g[i][j] = true;
        }
    }

    int dx[] = {0, 0, -1, 1};
    int dy[] = {-1, 1, 0, 0};

    for (int i = 0; i < q; ++i) {
        char op;
        int x, y;
        cin >> op >> x >> y;
        int k;
        if (op == 'c') {
            g[x][y] = false;
            continue;
        } else if (op == 'l') {
            k = 0;
        } else if (op == 'r') {
            k = 1;
        } else if (op == 'u') {
            k = 2;
        } else {
            k = 3;
        }
        int xx = x + dx[k], yy = y + dy[k];
        while (xx >= 1 && xx <= m && yy >= 1 && yy <= n) {
            if (g[xx][yy]) {
                cout << xx << " " << yy << endl;
                break;
            }
            xx += dx[k];
            yy += dy[k];
        }
        if (xx >= 1 && xx <= m && yy >= 1 && yy <= n)continue;
        puts("-1");
    }

    return 0;
}